package com.wiiss.ams.util;

import cn.hutool.log.StaticLog;

import java.util.concurrent.Executors;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 多线程执行器 单例
 * @author 52291590 2022年11月16日 上午11:40:56
 */
public class Executor {

    private static final ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(16, 1024, 64L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), Executors.defaultThreadFactory(),
            (r, e) -> StaticLog.error("The task cannot be executed by {}, task: {}", e.toString(), r.toString()));

    public static ThreadPoolExecutor getInstance() {
        return EXECUTOR;
    }

    private Executor() {}

}
